<?php
Loader::loadFile('config.php', "modules/InnoForum");

Loader::loadClass('DateUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('ObjectUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('PNObjectEx', "modules/InnoForum/pnincludes");
Loader::loadClass('PNObjectExArray', "modules/InnoForum/pnincludes");
Loader::loadClass('DBUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('SecurityUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('InnoUtil', "modules/InnoForum/pnincludes");

/**
 * initialise block
 * 
 * @author       The PostNuke Development Team
 */
function InnoForum_UserMenublock_init()
{

}

/**
 * get information on block
 * 
 * @author       The PostNuke Development Team
 * @return       array       The block information
 */
function InnoForum_UserMenublock_info()
{
    return array('text_type'      => 'User menu',
                 'module'         => 'InnoForum',
                 'text_type_long' => 'User menu / login',
                 'allow_multiple' => true,
                 'form_content'   => false,
                 'form_refresh'   => false,
                 'show_preview'   => true);
}

/**
 * display block
 * 
 * @author       The PostNuke Development Team
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the rendered bock
 */
function InnoForum_UserMenublock_display($blockinfo)
{
    $modname  = 'InnoForum';

    $vars = pnBlockVarsFromContent($blockinfo['content']);
    $lang = pnUserGetLang();
    if (file_exists('modules/InnoForum/pnlang/' . $lang . '/user.php')){
      Loader::loadFile('user.php', 'modules/InnoForum/pnlang/' . $lang );
    }else if (file_exists('modules/InnoForum/pnlang/eng/user.php')){
      Loader::loadFile('user.php', 'modules/InnoForum/pnlang/eng' );
    }
    
    $render = pnRender::getInstance('InnoForum');
    $render->assign('is_loggedin' , pnUserLoggedIn());
    $render->assign('user',   InnoUtil::getUserInfo());

    // Populate block info and pass to theme
    $blockinfo['content'] = $render->fetch('block_usermenu.htm');
    return themesideblock($blockinfo);

}


/**
 * modify block settings
 * 
 * @author       The PostNuke Development Team
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the bock form
 */
/*
function InnoForum_UserMenublock_modify($blockinfo)
{
  $vars = pnBlockVarsFromContent($blockinfo['content']);
  //load render
  $render = pnRender::getInstance('InnoForum');
  $render->assign('form', $vars);
  
	return $render->fetch('block_usermenu_modify.htm');
}
*/

/**
 * update block settings
 * 
 * @author       The PostNuke Development Team
 * @param        array       $blockinfo     a blockinfo structure
 * @return       $blockinfo  the modified blockinfo structure
 */
/*
function InnoForum_UserMenublock_update($blockinfo)
{
    
    // Get current content
    $vars = pnBlockVarsFromContent($blockinfo['content']);
    
    // clear the block cache
    $pnRender = pnRender::getInstance('InnoForum');
    $pnRender->clear_cache('block_usertopics.htm');
    
    return $blockinfo;
}*/
